package com.apex.sdk.utils;

import android.graphics.Bitmap;

import com.example.custom_dial.CustomDialCallback;
import com.example.custom_dial.CustomDiffTxtColorDialParam;
import com.example.custom_dial.DrawDiffTxtUtils;
import com.example.custom_dial.HLCustomPointDialParam;
import com.example.custom_dial.HLPointUtils;

public class HLDialUtils {

    /**
     * 创建文字表盘缩略图
     *
     * @param backBitmap
     * @param startY
     * @param drawDiffTxtUtils
     * @param dateY
     * @param txtColor
     * @return
     */
    public Bitmap createTxtPreviewDial(Bitmap backBitmap, int startY, DrawDiffTxtUtils drawDiffTxtUtils, int dateY, int txtColor, int screenWidth, int screenHigh) {
        if (screenWidth == 240 && screenHigh == 240) {
            return drawDiffTxtUtils.produceDialThumbnail(backBitmap, 240, 240, 140, 1, 40,
                    startY, 75, dateY, txtColor, 115);
        }else if (screenWidth==240&&screenHigh==296){
            return drawDiffTxtUtils.produceDialThumbnail(backBitmap, 240, 296, 32, 0, 40,
                    startY, 75, dateY, txtColor, 115);
        }else {
                return drawDiffTxtUtils.produceDialThumbnail(backBitmap, 360, 360, 90, 1, 86, startY, 110, dateY, txtColor, 190);

        }
    }

    /**
     * 创建文字表盘文件
     *
     * @param backBitmap
     * @param startY
     * @param drawDiffTxtUtils
     * @param dateY
     * @param txtColor
     * @param customDialCallback
     */
    public void createTxtDialBin(Bitmap backBitmap, int startY, DrawDiffTxtUtils drawDiffTxtUtils, int dateY, int txtColor, CustomDialCallback customDialCallback, int screenWidth,int screenHigh) {
        CustomDiffTxtColorDialParam customDiffTxtColorDialParam = new CustomDiffTxtColorDialParam();
        customDiffTxtColorDialParam.setTxtColor(txtColor);
        customDiffTxtColorDialParam.setBackBitmap(backBitmap);
        if (screenWidth == 240) {
            if (screenHigh==240) {
                customDiffTxtColorDialParam.setCornerRadius(70);
                customDiffTxtColorDialParam.setScreenType(1);
                customDiffTxtColorDialParam.setScreenWidth(240);
                customDiffTxtColorDialParam.setScreenHigh(240);
                customDiffTxtColorDialParam.setpWidth(140);
                customDiffTxtColorDialParam.setpHigh(140);
                customDiffTxtColorDialParam.setStartX(40);
                customDiffTxtColorDialParam.setStartY(startY);
                customDiffTxtColorDialParam.setWy(dateY);
                customDiffTxtColorDialParam.setWx(75);
                customDiffTxtColorDialParam.setDateX(115);
            }else{
                customDiffTxtColorDialParam.setCornerRadius(32);
                customDiffTxtColorDialParam.setScreenType(0);
                customDiffTxtColorDialParam.setScreenWidth(240);
                customDiffTxtColorDialParam.setScreenHigh(296);
                customDiffTxtColorDialParam.setpWidth(160);
                customDiffTxtColorDialParam.setpHigh(188);
                customDiffTxtColorDialParam.setStartX(40);
                customDiffTxtColorDialParam.setStartY(startY);
                customDiffTxtColorDialParam.setWy(dateY);
                customDiffTxtColorDialParam.setWx(75);
                customDiffTxtColorDialParam.setDateX(115);
            }

        } else {
            customDiffTxtColorDialParam.setCornerRadius(90);
            customDiffTxtColorDialParam.setScreenType(1);
            customDiffTxtColorDialParam.setScreenWidth(360);
            customDiffTxtColorDialParam.setScreenHigh(360);
            customDiffTxtColorDialParam.setpWidth(180);
            customDiffTxtColorDialParam.setpHigh(180);
            customDiffTxtColorDialParam.setStartX(86);
            customDiffTxtColorDialParam.setStartY(startY);
            customDiffTxtColorDialParam.setWx(90);
            customDiffTxtColorDialParam.setWy(dateY);
            customDiffTxtColorDialParam.setDateX(160);
        }
        drawDiffTxtUtils.produceDialBin(customDiffTxtColorDialParam, customDialCallback);

    }

    /**
     * @param hlPointUtils
     * @param backBitmap   背景图
     * @param preBitmap    风格缩略图
     * @return
     */
    public Bitmap createPointPreviewDial(HLPointUtils hlPointUtils, Bitmap backBitmap, Bitmap preBitmap,int screenWidth,int screenHigh) {
        if (screenWidth==240&&screenHigh==240) {
            return hlPointUtils.produceDialThumbnail(backBitmap, 240, 240, 140, 1, preBitmap);
        }else if (screenWidth==240&&screenHigh==296){
            return hlPointUtils.produceDialThumbnail(backBitmap, 240, 296, 32, 0, preBitmap);
        }else if (screenWidth==360&&screenHigh==360){
            return hlPointUtils.produceDialThumbnail(backBitmap, 360, 360, 180, 1, preBitmap);
        }else{
            return null;
        }

    }

    public void createPointDialBin(HLPointUtils hlPointUtils, Bitmap backBitmap, Bitmap preBitmap, Bitmap hourBitmap, Bitmap minuteBitmap, Bitmap secondBitmap, CustomDialCallback customDialCallback, int screenWidth,int screenHigh) {
        HLCustomPointDialParam hlCustomPointDialParam = new HLCustomPointDialParam();
        hlCustomPointDialParam.setSecondBitmap(secondBitmap);
        hlCustomPointDialParam.setMinuteBitmap(minuteBitmap);
        hlCustomPointDialParam.setHourBitmap(hourBitmap);
        hlCustomPointDialParam.setPreviewBitmap(preBitmap);
        hlCustomPointDialParam.setBackBitmap(backBitmap);
        if (screenWidth == 240) {
            if (screenHigh==240) {
                hlCustomPointDialParam.setPreviewWidth(140);
                hlCustomPointDialParam.setPreviewHigh(140);

                hlCustomPointDialParam.setScreenType(1);
                hlCustomPointDialParam.setCornerRadius(70);
                hlCustomPointDialParam.sethTop(54);
                hlCustomPointDialParam.setmTop(24);
                hlCustomPointDialParam.setsTop(9);
                hlCustomPointDialParam.setScreenWidth(240);
                hlCustomPointDialParam.setScreenHigh(240);
            }else{
                hlCustomPointDialParam.setPreviewWidth(160);
                hlCustomPointDialParam.setPreviewHigh(188);

                hlCustomPointDialParam.setScreenType(0);
                hlCustomPointDialParam.setCornerRadius(32);
                hlCustomPointDialParam.sethTop(88);
                hlCustomPointDialParam.setmTop(49);
                hlCustomPointDialParam.setsTop(37);
                hlCustomPointDialParam.setScreenWidth(240);
                hlCustomPointDialParam.setScreenHigh(296);
            }
        } else {
            hlCustomPointDialParam.setPreviewWidth(180);
            hlCustomPointDialParam.setPreviewHigh(180);

            hlCustomPointDialParam.setScreenType(1);
            hlCustomPointDialParam.setCornerRadius(90);
            hlCustomPointDialParam.sethTop(78);
            hlCustomPointDialParam.setmTop(30);
            hlCustomPointDialParam.setsTop(20);
            hlCustomPointDialParam.setScreenWidth(360);
            hlCustomPointDialParam.setScreenHigh(360);
        }
        hlPointUtils.produceDialBin(hlCustomPointDialParam, customDialCallback);
    }
}
